<h5>Interfacing the Wiring hardware and Perl</h5>
<p>This tutorial introduces the basic interfacing between the Wiring hardware and and Perl <a href="http://www.perl.org/">http://www.perl.org/</a>. The brief for the tutorial will be to send data to the Wiring board, the Wiring board will read the data and turn ON or OFF the board LED accordingly. It assumes the Wiring software and Perl are installed and the proper Wiring setup has been previously completed. For more Information on Wiring install check out the tutorials about Wiring installation and software setup.</p>
<p>For this tutorial, the used IDE is Eclipse <a href="http://www.eclipse.org/">http://www.eclipse.org/</a>with EPIC <a href="http://www.epic-ide.org/">http://www.epic-ide.org/</a> as the Perl editor.</p>
<h5>Step 1</h5>
<p>Copy and paste the following code on the Wiring editor: Verify your program is free of compiling errors by pressing the Compile/Verify button in the menu bar. Press the Upload button in the menu bar. In case of syntax errors the Wiring environment will print the error messages otherwise it will print the Upload was completed successfully, the uploading process triggers activity in the Rx/Tx LEDs on the Wiring hardware. The new program will start automatically after uploading. Use the Serial Monitor button to watch the data coming from the Wiring board, then close the Serial Monitor again.</p>
<pre>
/**
 * Simple Read/ Perl
 * 
 * Read data from the serial port and turn ON the onboard LED if
 * the character received is an 'a'
 * For the Wiring boards v1 the on-board LED is on pin 48, 
 * on Wiring S the on-board LED is on pin 15.
 */

int data; // to read the char

void setup() {
  Serial.begin(9600);
  pinMode(WLED, OUTPUT);
}

void loop() {
  if(Serial.available()) {      // if data available
    data = Serial.read();       // read data
    if(data == 'H') {           // if value read is character 'a'
      digitalWrite(WLED, HIGH); // turn ON the onboard LED
    } else {
      digitalWrite(WLED, LOW);  // if not turn it OFF
    }
  }
  delay(100); // wait 100ms for next read
}
</pre>
<h5>Step 2</h5>
<p>Download and install the perl´s package named Device::SerialPort using Terminal or Command Prompt for Windows. Use the next lines of code to make the installation. </p>
<pre>
perl -MCPAN -e shell
install Device::SerialPort
exit</pre>
<h5>Step 3</h5>
<p>Create a new Perl project in Eclipse. Copy and paste the next code in the editor.</p>
<pre>
#!/usr/bin/perl
use Device::SerialPort;

# Set up the serial port
# Change the port
my $port = Device::SerialPort->new("/dev/tty.usbserial-A100DNHF");
# Change the baudrate if you need it
$port->baudrate(9600);
$port->databits(8);
$port->parity(10);
$port->stopbits(1);

sleep(4);

while (1) {
	$port->write('H');
	sleep(1);
	$port->write('L');
	sleep(1);
}</pre>
<h5>Step 4</h5>
<p>Compile the project adn the LED board must blink every second.</p>
